package com.sunday.volunteer.ui;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.EditText;
import android.widget.TextView;

import com.sunday.common.utils.ToastUtils;
import com.sunday.member.base.BaseActivity;
import com.sunday.volunteer.R;
import com.sunday.volunteer.utils.BaseUtil;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Pual's PC on 2016/10/25.
 */
public class EditTextActivity extends BaseActivity {

    @Bind(R.id.title_text)
    TextView title_text;
    @Bind(R.id.edit_text)
    EditText edit_text;
    @Bind(R.id.title_right_text)
    TextView title_right_text;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_edittext);
        ButterKnife.bind(this);

        title_right_text.setText("确定");
        title_text.setText(getIntent().getStringExtra(BaseUtil.TITLE));
        edit_text.setText(getIntent().getStringExtra(BaseUtil.CONTENT));
        edit_text.setHint("请输入"+getIntent().getStringExtra(BaseUtil.TITLE));

    }

    @OnClick(R.id.title_right_text)
    void title_text(){
        if(TextUtils.isEmpty(edit_text.getText().toString())){
            ToastUtils.showToast(mContext ,"请输入"+getIntent().getStringExtra(BaseUtil.TITLE));
            return;
        }
        Intent intent = new Intent();
        intent.putExtra(BaseUtil.CONTENT , edit_text.getText().toString());
        setResult(RESULT_OK ,intent);
        finish();
    }

}
